package com.ourteam.product.api;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.ui.dao.IProductUITreeNodeBuilderDAO;
import com.ourteam.product.ui.dao.ProductUITreeNodeBuilderDAOQueryBean;
import com.ourteam.product.ui.domain.ProductUITreeNodeBuilderBean;

public class ProductUITreeNodeBuilderSearchModel extends AbstractSearchModel<ProductUITreeNodeBuilderDAOQueryBean> {

	private long treeNodeId;

	public long getTreeNodeId() {
		return treeNodeId;
	}

	public void setTreeNodeId(long treeNodeId) {
		this.treeNodeId = treeNodeId;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductUITreeNodeBuilderBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductUITreeNodeBuilderDAOQueryBean queryBean) throws Exception {

		ProductUITreeNodeBuilderDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		criteria.andNodeIdEqualTo(treeNodeId);

		if (queryBean.getSortProperties().isEmpty()) {
			queryBean.setSortProperty(IProductUITreeNodeBuilderDAO.SortIndex);
		}

	}

}
